package com.zhengxin.one.controller;

import com.zhengxin.one.common.Result;
import com.zhengxin.one.entity.Menu;
import com.zhengxin.one.entity.User;
import com.zhengxin.one.entity.entityClass.RsyTotal;
import com.zhengxin.one.service.impl.MeunServiceIpml;
import org.omg.CORBA.OBJ_ADAPTER;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "shangshebao")
public class MeunController {
    //目录获取
    @Autowired
    private MeunServiceIpml meunService;
    @RequestMapping(value = "getMenu", method = RequestMethod.GET)
    public List<Menu> getMenu() {
        List<Menu> list = meunService.Smenu();
        return list;
    }

    @RequestMapping(value = "getMenus", method = RequestMethod.GET)
    public Result getMenus(@RequestParam String staff_id) {
        //查询权限表 访问目录
        List<String> list = meunService.getMenus(staff_id);
        List<Menu> aa = new LinkedList();
        for (String x:list) {
            Menu info = meunService.getMenuss(x);
            aa.add(info);
        }
        return Result.success(aa);
    }
    //获取社保和公积金参保地
    @RequestMapping(value = "getArea", method = RequestMethod.GET)
    public Result getArea(@RequestParam int type) {
        //type1是社保2是公积金
        return Result.success(meunService.getAdders(type));
    }
    //获取方案
    @RequestMapping(value = "getPlan", method = RequestMethod.GET)
    public Result getPlan(@RequestParam int type ,@RequestParam String addr_name) {
        //type1是社保2是公积金3是商保
        if(type==1){

            return Result.success(meunService.getSps(addr_name));
        }
        if(type==2){

            return Result.success(meunService.getAps(addr_name));
        }
        if(type==3){

            return Result.success(meunService.getCps());
        }
        return Result.fail("操作失败");
    }

}
